package com.qf.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
* 配置交换机，队列；
* */
@Configuration
public class RabbitMQConfig {
    public static final String TOPICEXCHANG="boot_topic_exchange";
    public static final String TOPICQ1="Q1";
    public static final String TOPICQ2="Q2";

    @Bean
    public Queue topicQ1(){
        return new Queue(TOPICQ1);
    }

    @Bean
    public Queue topicQ2(){
        return QueueBuilder.durable(TOPICQ2).build();
    }
    @Bean
    public Exchange topicExchange(){
        return ExchangeBuilder.topicExchange(TOPICEXCHANG).build();
    }
    //绑定
    @Bean
    public Binding topicEBindingToTopicQ1(){
        return BindingBuilder
                .bind(topicQ1())
                .to(topicExchange()).with("*.orange.*")
                .noargs();//绑定时构建；
    }
    @Bean
    public Binding topicEBindingToTopicQ2A(){
        return BindingBuilder
                .bind(topicQ2())
                .to(topicExchange()).with("*.*.rabbit")
                .noargs();//绑定时构建；
    }

    @Bean
    public Binding topicEBindingToTopicQ2B(){
        return BindingBuilder
                .bind(topicQ2())
                .to(topicExchange()).with("lazy.#")
                .noargs();//绑定时构建；
    }


}
